package cn.piesat.scanning.business.xz.service.gseimpl;

import cn.hutool.core.util.StrUtil;
import cn.piesat.scanning.business.xz.service.BuildAlgorithmTaskService;
import cn.piesat.scanning.business.xz.single.AlgorithmTaskPathParam;
import cn.piesat.scanning.business.xz.single.AlgorithmTaskRuleParam;
import cn.piesat.scanning.dto.HtScanningMetadataDTO;
import cn.piesat.scanning.service.HtScanningMetadataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author Ming
 * @version 1.0
 * @description: TODO
 * @date 2023/12/18 13:48
 */
@Service
public class BuildTibet_Grass_GSLServiceImpl implements BuildAlgorithmTaskService {

    @Autowired
    private HtScanningMetadataService htScanningMetadataService;
    @Override
    public Map<String, Object> initAlgorithmParams(String adsType, String primaryFile, String filePath, AlgorithmTaskRuleParam taskRuleParam, AlgorithmTaskPathParam taskPathParam, Map<String, Integer> indexParams, String fileDate, String scanningPath,HtScanningMetadataDTO htScanningMetadataDTO) {
        Map<String, Object> algorithmParams = new HashMap<>();
        Map<String, Object> params = new HashMap<>();
        String fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
        String[] s = fileName.split("_");
        String moduleIid = s[0];
        String productMode = s[8];
        params.put("primaryFile", primaryFile);
        HtScanningMetadataDTO metadataDTO = htScanningMetadataService.findMeatedataByMoudel(s[9], taskPathParam.getParameter04(), taskPathParam.getParameter07(),
                taskPathParam.getParameter05(), taskPathParam.getParameter06(), productMode, moduleIid, taskPathParam.getParameter08());
        params.put("lastFile", taskPathParam.getParameter02() + File.separator + metadataDTO.getFilePath());
        params.put("auxPath", taskPathParam.getParameter03());
        algorithmParams.put("parameter00", adsType);
        algorithmParams.put("parameter01", params);
        return algorithmParams;
    }
}
